# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=calligra
pkgver=3.2.1
pkgrel=46
pkgdesc="Office and graphic art suite by KDE"
# armhf blocked by extra-cmake-modules
# ppc64le, s390x and riscv64 blocked by qt5-qtwebengine -> okular
arch="all !armhf !ppc64le !s390x !riscv64"
url="https://calligra.org/"
license="GPL-2.0-or-later AND LGPL-2.0-only"
makedepends="
	attica5-dev
	boost-dev
	eigen-dev
	extra-cmake-modules
	kactivities5-dev
	karchive5-dev
	kcmutils5-dev
	kcodecs5-dev
	kcompletion5-dev
	kconfig5-dev
	kconfigwidgets5-dev
	kcoreaddons5-dev
	kdbusaddons5-dev
	kdelibs4support-dev
	kdiagram-dev
	kdoctools5-dev
	kguiaddons5-dev
	ki18n5-dev
	kiconthemes5-dev
	kio5-dev
	kitemviews5-dev
	kjobwidgets5-dev
	knewstuff5-dev
	knotifications5-dev
	knotifyconfig5-dev
	kparts5-dev
	kross-dev
	ktextwidgets5-dev
	kwallet5-dev
	kwidgetsaddons5-dev
	kwindowsystem5-dev
	kxmlgui5-dev
	poppler-qt5-dev
	qt5-qtbase-dev
	qt5-qtdeclarative-dev
	qt5-qtquickcontrols2-dev
	qt5-qtsvg-dev
	qt5-qtx11extras-dev
	samurai
	sonnet5-dev
	threadweaver5-dev
	"
# Dependencies for extra features
makedepends="$makedepends
	libgit2-dev
	libodfgen-dev
	libvisio-dev
	libwpg-dev
	okular-dev
	"
checkdepends="xvfb-run"
source="https://download.kde.org/stable/calligra/$pkgver/calligra-$pkgver.tar.xz
	poppler-22.03.patch
	poppler-22.04.patch
	gcc11.patch
	modernise-cmake.patch
	fontconfig-linking.patch
	"
subpackages="$pkgname-doc $pkgname-lang"
options="!check" # Broken tests https://bugs.kde.org/show_bug.cgi?id=423989

build() {
	cmake -B build -G Ninja \
		-DCMAKE_CXX_STANDARD=17 \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DGHNS=ON \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)"
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
e53a939aa1b277c2291cfd626868c77085fc9cc7774df160b5b1afceb33314b4381fa8ffe03636cbde6e35cc2abd170a51e7f9c1a99191339313b9c9c3b1526f  calligra-3.2.1.tar.xz
f20c129525fe8665393d7f02758e070e953729e793235ccdda18478f925a10786141b73babae5ac6b68d9878dda41b437f3ce6b750dfae97de757c9d5852f283  poppler-22.03.patch
2654b3f1dc8d1863ac4efd2ababe97171963a9a3c6275c422ec04fa802e4764ceb63ea1511edeed4feedced2282cf0fe67282f522f397961b0a940ad88f0def2  poppler-22.04.patch
8c56ac0e3347f97bb44d6abf4e3c2303898ce7a4556e0264440ba928e159e978f858a730c9ed07dcde2f0fdc32228d3cc5a565574bf52f43a53475501a640bc4  gcc11.patch
bbf56c7489af184fe3710108ce43b610f9723cbdf49246bc2bdff4d86d9171693afc64d6072680e6f785f8b15aea509ea0e8cfb84424d1ef1b4d3e876630005f  modernise-cmake.patch
050d8a80cb2827cbd83835e198014a7a2c33b38a7200e9b5b07d80d4c2e801d0ac7879f7ed06ea9454e1eb37d617c1fe39db6f5a50466afddb9cdef18264c4b6  fontconfig-linking.patch
"
